package de.dhbw.karlsruhe.picsim.gui.renderer;

import de.dhbw.karlsruhe.picsim.gui.data.OpCodeGui;
import de.dhbw.karlsruhe.picsim.util.Bits;
import de.dhbw.karlsruhe.picsim.util.impl.BitUtilities;

import javax.swing.*;

/**
 * Created by IntelliJ IDEA. User: goesen Date: Apr 15, 2010 Time: 2:26:28 PM
 */
public final class OpCodeRenderer extends ProgramRenderingSupport {


    @Override
    public JComponent getRenderingComponent(final OpCodeGui opcode, final JTable jtable, final int row,
                                            final int column) {

        final Bits data = opcode.getData();
        String hexString = Integer.toHexString(BitUtilities.fromLeastSignificantBitFirst(data));
        hexString = hexString.toUpperCase();
        while (hexString.length() < 4) {
            hexString = 0 + hexString;
        }
        setText(hexString);
        return this;
    }
}

